
//持久化 pinia 状态
// import { createPinia } from 'pinia';

export const persistPlugin = ({ store }) => {
// 从 localStorage 恢复状态
    const saved = localStorage.getItem(store.$id)
    if (saved) store.$patch(JSON.parse(saved))
// 监听变化并保存
    store.$subscribe((_, state) => {
        localStorage.setItem(store.$id, JSON.stringify(state))
    })
}